import { useContext } from 'react'
import { Empty } from 'antd'
import { isNullArray } from '@/utils'
import { reportReviewContext } from '../../_context'
import CardDataVarable from '@/components/CardDataVarable'
import styles from '../../index.module.less'

export default () => {
  const { reviewInfo, switchChecked } = useContext(reportReviewContext)

  return (
    <>
      {isNullArray(reviewInfo?.sortPlatformVos) &&
        reviewInfo?.sortPlatformVos.map((item) => (
          <CardDataVarable key={item.id} text={item.sortName}>
            <div className={styles['cart-list']}>
              {isNullArray(item.variablePlatformVos) &&
                item.variablePlatformVos.map((val) => (
                  <div key={val.id} className={styles['cart-list-info']}>
                    {switchChecked ? (
                      <>
                        {val.updateVariableValue ? (
                          <>
                            <div className={styles['cart-list-info-title']}>{val.variableName}</div>
                            <div className={styles['cart-list-info-data']}>
                              <div className={styles['cart-list-info-data-value']}>{val.variableValue}</div>
                              <div className={styles['cart-list-info-data-txt']}>修改为</div>
                              <div className={styles['cart-list-info-data-value']}>{val.updateVariableValue}</div>
                            </div>
                          </>
                        ) : (
                          <Empty style={{ flex: '1' }} />
                        )}
                      </>
                    ) : (
                      <>
                        <div className={styles['cart-list-info-title']}>{val.variableName}</div>
                        {val.updateVariableValue ? (
                          <div className={styles['cart-list-info-data']}>
                            <div className={styles['cart-list-info-data-value']}>{val.variableValue}</div>
                            <div className={styles['cart-list-info-data-txt']}>修改为</div>
                            <div className={styles['cart-list-info-data-value']}>{val.updateVariableValue}</div>
                          </div>
                        ) : (
                          <div className={styles['cart-list-info-data']}>
                            <div className={styles['cart-list-info-data-value']}>{val.variableValue}</div>
                          </div>
                        )}
                      </>
                    )}
                  </div>
                ))}
            </div>
          </CardDataVarable>
        ))}
    </>
  )
}
